
<div class="modal-dialog">
    <div class="modal-content">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
            <h4 class="modal-title" id="title">管理员设置</h4>
        </div>
        <div class="modal-body">
            <div class="container-fluid">
                <form id="editForm" class="form-horizontal">
                    <input type="hidden" class="form-control" id="id" name="id"  value="{$userInfo.id}">
                    <div class="form-group">
                        <label for="cnName" class="col-sm-2 control-label">姓名</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id="cnName" name="cnName" placeholder="姓名" disabled value="{$userInfo.area}-{$userInfo.building}-{$userInfo.house}-{$userInfo.accountName}">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="role" class="col-sm-2 control-label">管理员</label>
                        <div class="col-sm-10">
                            <select id="role" name="role" class="form-control">
                                <option value="0" <if condition="$userInfo.role eq 0"> selected </if> >成员</option>
                                <option value="1" <if condition="$userInfo.role eq 9"> selected </if> >投诉建议管理员</option>
                                <option value="2" <if condition="$userInfo.role eq 99"> selected </if> >普通管理员</option>
                                <option value="3" <if condition="$userInfo.role eq 999"> selected </if> >超级管理员</option>
                            </select>
                        </div>
                    </div>
                </form>
            </div>
        </div>
        <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            <button type="button" class="btn btn-primary" id="updateBtn">确定</button>
        </div>
    </div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->

<script>
    $("#editForm").validate({
        rules: {
            category: {
                required: true
            }
        },
        messages: {
            category: {
                required: "请选择分组"
            }
        }
    });
    $("#updateBtn").on("click",function(){
        if($("#editForm").valid()){
            var formData = $("#editForm").serialize();
            $.ajax({
                type: "POST",
                dataType: 'json',
                url: "__URL__/updateRoleAjax",
                data: formData,
                success: function onSuccess(data, status)
                {
                    if(data.code > 0 ){
                        alertMsg(data.msg, {icon:'warning'});
                    }
                    else{
                        $("#roleModal").modal("hide");
                        alertMsg(data.msg, {icon:'succeed'});
                        $('#list').DataTable().ajax.reload();
                    }
                },
                error: function onError(data, status)
                {
                    // handle an error
                }
            });
        }
        return false;
    });
</script>        